Skip to content

fix: repair all failing tests and type errors#46

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2477-1781024716
Open

fix: repair all failing tests and type errors#46
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2477-1781024716

Conversation

@stooit

@stooit stooit commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and TypeScript errors across the api and shared packages. Final state: 22 pass / 0 fail and tsc --noEmit exits 0.

Root causes & fixes

  • Shared types field-name mismatchUser.userName renamed to username (lowercase) to match every consumer (db, route handler, and all tests). This was the source of the username type errors and the POST /users validation failure.
  • Missing importroutes/users.ts used badRequest without importing it from lib/errors; added to the import.
  • Auth middleware case-sensitivity bug — the public-route allowlist compared against "post", but Hono's c.req.method is uppercase, so unauthenticated POSTs were wrongly forced through the auth check. Changed to "POST".
  • Pagination stub — implemented paginate() in shared/utils/pagination.ts per the test contract (page slice, partial last page, total/totalPages rounding, out-of-range page, empty array).
  • tsconfig — switched to "types": ["bun-types"] so bun:test and process/Bun globals resolve, clearing the remaining tsc errors. (bun-types was already installed — no new dependency.)

Verification

  • bun test -> 22 pass, 0 fail
  • npx tsc --noEmit -> 0 errors

Constraints honoured

  • No test files modified
  • No new dependencies added
  • Only changes required by the tests

Assumptions / notes

  • Canonical user field name resolved to username (lowercase) because the immutable tests use that spelling consistently.
  • paginate() does not guard size <= 0. No test exercises this and page size is not user-controllable today, so it was left out per "fix only what the tests require" — flagged for future hardening.

- shared: rename User field userName -> username for cross-package consistency
- api/users route: import missing badRequest error helper
- api/auth middleware: fix case-sensitive HTTP method allowlist (post -> POST)
- shared/pagination: implement paginate() per test contract
- tsconfig: use bun-types so bun:test and process globals resolve
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant